# 1.导入pymysql
import pymysql

# 2.创建链接对象

conn = pymysql.connect(user='root', password='root',
                       database='advanced', charset='utf8')

# 3.获取游标对象
cursor = conn.cursor(cursor=pymysql.cursors.DictCursor)

# 4.执行sql语句
sql = 'select * from student'
rows = cursor.execute(sql)
print(rows)

# 5.获取结果集
print(cursor.fetchone())
print(cursor.fetchall())
# 6.7关闭
cursor.close()
conn.close()


